package server.exchange;

public class Order {
	private Client client;
	private OPERATIONTYPE operationType;
	private ORDERSTATUS status=ORDERSTATUS.RENDING;
	private String stockName;
	private int numberOfShares;
	private int id;
	float price;
	
	public Order(Client client, OPERATIONTYPE operationType, String stockName,
			int numberOfShares, float price,int id) {
		super();
		this.client = client;
		this.operationType = operationType;
		this.stockName = stockName;
		this.numberOfShares = numberOfShares;
		this.price = price;
		this.id=id;
	}
	
	public Order(Client client, OPERATIONTYPE operationType, String stockName,
			int numberOfShares, float price,int id, ORDERSTATUS status) {
		super();
		this.client = client;
		this.operationType = operationType;
		this.stockName = stockName;
		this.numberOfShares = numberOfShares;
		this.price = price;
		this.id=id;
		this.status=status;
	}
	
	public int getId(){
		return this.id;
	}
	public OPERATIONTYPE getOpperationType(){
		return this.operationType;
	}
	public int getnamberOfShares(){
		return this.numberOfShares;
	}
	public void getNShares(int n){
		this.numberOfShares-=n;
	}


	
	public String getStockName() {
		return stockName;
	}
	
	public String getClientName(){
		return this.client.getName();
	}

	public String toString(){
		return this.operationType.toString()+" "+this.client.getName()+" :"+this.stockName+" x"+this.numberOfShares+" at price "+this.price+ " status "+ this.status.toString();
	}

	public ORDERSTATUS getStatus() {
		return status;
	}

	public void setStatus(ORDERSTATUS status) {
		this.status = status;
	}
	
	public boolean isCorrect(){
		boolean fl=true;
		if (this.price<=0) fl=false;
		if (this.numberOfShares<1) fl=false;
		return fl;
	}
	
	public Order getMyself(){
		return new Order(this.client, this.operationType, this.stockName, this.numberOfShares, this.price, this.id, this.status);
	}
	
	
	
}
